{extend name="common/common" /} {block name="style"}
<style type="text/css">
	.container-fluid .btn {
		float: right;
		margin-left: 10px;
	}
	.btn.btn-sm { 
		margin: 0;
	}
	.layui-input-block{
		margin-left: 80px;
	}
	#layTestTime,#laySchoolRoll{
		display: none;
		padding: 15px;
	}
	.layui-form-label{
		width: 90px;
	}
	.layui-input.layui-unselect{
		width: 100px;
	}
	.layui-anim.layui-anim-upbit{
		width: 100px;
	}
</style>
{/block} {block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="ibox float-e-margins">
		<div class="ibox-title">
			<h5>学员列表</h5>
		</div>
		<div class="ibox-content">
			<form class="layui-form" action="" id="seaForm">
				<div class="layui-form-item">
					<div class="layui-input-inline" style="width: 150px;">
						<input type="text" name="seaPhone" id="seaPhone" placeholder="手机" class="layui-input">
					</div>
					<div class="layui-input-inline" style="width: 150px;">
						<input type="text" name="seaName" id="seaName" placeholder="学员姓名" class="layui-input">
					</div>
					<div class="layui-input-inline" style="width: 150px;">
						<input type="text" name="seaSchool" id="seaSchool" placeholder="学校" class="layui-input">
					</div>
					<div class="layui-input-inline" style="width: 150px;">
						<input type="text" name="seaMajor" id="seaMajor" placeholder="专业" class="layui-input">
					</div>
					<div class="layui-input-inline" style="width: 150px;">
						<input type="text" name="seaBatch" id="seaBatch" placeholder="批次" class="layui-input">
					</div>
					<div class="layui-input-inline" style="width: 150px;">
						<input type="text" name="seaClass" id="seaClass" placeholder="班级" class="layui-input">
					</div>
					<div class="layui-input-inline" style="width: 100px;">
						<select name="seaRollStatus" id="seaRollStatus">
							<option value="">有无异常</option>
							<option value="0">无</option>
							<option value="1">有</option>
						</select>
					</div>

					<div class="layui-input-inline" style="width: 100px;">
						<select name="seaSchoolRoll" id="seaSchoolRoll">
							<option value="">学籍状态</option>
							<option value="1">在读</option>
							<option value="2">毕业</option>
							<option value="3">休学</option>
							<option value="4">退学</option>
						</select>
					</div>

					<div class="layui-inline">
						<button type="button" id="search" class="btn btn-info" style="margin-top: 2px;">查询</button>
					</div>

				</div>
			</form>
			<div class="container-fluid">
				<div class="container-fluid">
					{if authCheck('trash/stdelete')}
						<a class="btn btn-danger getIDs" href="javascript:deleteST();" data-param=''>删除学员</a>
					{/if}
					{if authCheck('trash/strecovery')}
						<a class="btn btn-primary getIDs" href="javascript:recoveryST();" data-param=''>恢复学员</a>
					{/if}
				</div>
			</div>
			<table id="cusTable">
				<thead>
					<th>checkbox</th>
					<th class="text-center" data-field="id">ID</th>
					<th class="text-center" data-field="name">学员姓名</th>
					<th class="text-center" data-field="school">学校</th>
					<th class="text-center" data-field="major">专业</th>
					<th class="text-center" data-field="batch">批次</th>
					<th class="text-center" data-field="class">班级</th>
					<th class="text-center" data-field="phone">手机</th>
					<th class="text-center" data-field="sex_name">性别</th>
					<th class="text-center" data-field="roll_status_name">有无异常变动</th>
					<th class="text-center" data-field="school_roll_name">学籍状态</th>
					<th class="text-center" data-field="operate">操作</th>
				</thead>
			</table>
		</div>
	</div>
</div>

{/block} {block name="script"}
<script type="text/javascript">
	var IDs = '';

	function initTable() {
		//先销毁表格
		$('#cusTable').bootstrapTable('destroy');
		//初始化表格,动态从服务器加载数据
		$("#cusTable").bootstrapTable({
			method: "get", //使用get请求到服务器获取数据
			url: "./student", //获取数据的地址
			striped: true, //表格显示条纹
			pagination: true, //启动分页
			pageSize: 10, //每页显示的记录数
			pageNumber: 1, //当前第几页
			pageList: [5, 10, 15, 20, 25], //记录数可选列表
			sidePagination: "server", //表示服务端请求
			paginationFirstText: "首页",
			paginationPreText: "上一页",
			paginationNextText: "下一页",
			paginationLastText: "尾页",
			queryParamsType: "undefined",
			columns: [{
				checkbox: true,
				formatter: function(value, row, index) {
					if (row.state == true) {
						return {
							checked: value, //设置选中
						};
					}
					return value;
				},
			}],
			queryParams: function queryParams(params) { //设置查询参数
				var param = {
					pageNumber: params.pageNumber,
					pageSize: params.pageSize,
					seaName: $("#seaName").val(),
					seaPhone: $("#seaPhone").val(),
					seaSchool: $("#seaSchool").val(),
					seaMajor: $("#seaMajor").val(),
					seaBatch: $("#seaBatch").val(),
					seaClass: $("#seaClass").val(),
					seaSchoolRoll:$("#seaSchoolRoll").val(),
					seaRollStatus:$("#seaRollStatus").val()
				};
				return param;
			},
			onLoadSuccess: function(res) { //加载成功时执行
				if (111 == res.code) {
					window.location.reload();
				}
				layer.msg("加载成功", {time: 1000});
			},
			onLoadError: function() { //加载失败时执行
				layer.msg("加载数据失败");
			}
		});
	}

	$(function() {
		//调用函数，初始化表格
		initTable();

		layui.use(['form','laydate'], function(){
	  		var form = layui.form;
	  	});

		//当点击查询按钮的时候执行
		$("#search").bind("click", initTable);

		$('.getIDs').on('click', function() {
			var checkedOn = $('#cusTable').bootstrapTable('getSelections');
			var IDs = '';
			for (var i = 0; i < checkedOn.length; i++) {
				if (i == 0) {
					IDs = checkedOn[0].id;
				} else {
					IDs += ',' + checkedOn[i].id;
				}
			}
			$('.getIDs').attr('data-param', IDs);
		});
	});

	function deleteST(ids = null) {
		if (ids == null) {
			ids = $('.getIDs').attr('data-param');
		}
		if (ids != '') {
			layer.confirm('确认删除这些数据?', {icon: 3,title: '提示'}, function(index) {
				$.post('./STdelete', {ids: ids}, function(res) {ResTab(res);});
			});
		} else {
			layer.msg("请选择数据", {anim: 6});
		}
	}

	function recoveryST(ids = null) {
		if (ids == null) {
			ids = $('.getIDs').attr('data-param');
		}
		if (ids != '') {
			layer.confirm('确认恢复这些数据?', {icon: 3,title: '提示'}, function(index) {
				$.post('./STRecovery', {ids: ids}, function(res) {ResTab(res);});
			});
		} else {
			layer.msg("请选择数据", {anim: 6});
		}
	}


	function ResTab(res){
		if (res.code == 1) {
			layer.alert(res.msg, {title: '友情提示',icon: 1,closeBtn: 0}, function(){
				layer.closeAll();
				initTable();
			});
		} else {
			layer.msg(res.msg, {anim: 6});
		}
	}
</script>
{/block}
